package org.subside.rabbitmq.TopicModel;

import com.rabbitmq.client.*;
import org.subside.rabbitmq.config.ConnectionUtil;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ProductorTopic {
    private static final String EXCHANGE_NAME = "exchange_topic";
 
    public static void main(String[] args) throws Exception {
        Connection connection =  ConnectionUtil.getConnection();
        Channel channel = null;
        try {
            channel = connection.createChannel();
            //aaa.good.add.aaa  这是ROUTINGKEY，它就相当于在mq里面已经
            channel.basicPublish(EXCHANGE_NAME, "aaa.good.add.aaa",null, "aaa.good.add.aaa".getBytes("UTF-8"));
            channel.basicPublish(EXCHANGE_NAME, "bbb.good.del.bbb",null, "bbb.good.add.bbb".getBytes("UTF-8"));
            channel.basicPublish(EXCHANGE_NAME, "ccc.good.all.ccc",null, "ccc.good.all.ccc".getBytes("UTF-8"));
 
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                channel.close();
                connection.close();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (TimeoutException e) {
                e.printStackTrace();
            }
        }
 
    }
}